package com.atguigu.lease.common.context;

public class LoginUserContext {
// todo 28 分的视频
    /*
    使用同一个线程来存储用户数据，根据用户id和username
     */
    private static final ThreadLocal<LoginUser> threadLocal = new ThreadLocal<>();
    public static void setLoginUser(Long userId,String username) {
        LoginUser loginUser = new LoginUser(userId, username);
        threadLocal.set(loginUser);
    }

    public static LoginUser getLoginUser() {
        return threadLocal.get();
    }

    public static void removeLoginUser() {
        threadLocal.remove();
    }
}
